//
// Created by 匡涂上青 on 2021/7/5.
//

#ifndef CSUGL_CAMERA_H
#define CSUGL_CAMERA_H

#include "../core/core.h"
#include "../vendor/glm/glm/glm.hpp"
#include "../vendor/glm/glm/gtc/matrix_transform.hpp"

namespace csugl {

    struct Transform;

    class Camera {
    public:
        explicit Camera(float aspect, float near, float far);
        glm::mat4 get_view_mat(const Transform& transform) const;
        virtual glm::mat4 get_projection_mat() const = 0;
        
        float aspect, near, far;
    };

    class OrthographicCamera : public Camera {
    public:
        OrthographicCamera(float aspect, float near, float far, float zoom);
        glm::mat4 get_projection_mat() const override;

        float zoom;

    public:
        static csugl::Ref<OrthographicCamera> Create(float aspect, float near, float far, float zoom)
        {
            return csugl::MakeRef<OrthographicCamera>(aspect, near, far, zoom);
        }
    };

    class PerspectiveCamera : public Camera {
    public:
        PerspectiveCamera(float aspect, float near, float far, float fov);
        glm::mat4 get_projection_mat() const override;

        float fov;

    public:
        static csugl::Ref<PerspectiveCamera> Create(float aspect, float near, float far, float fov)
        {
            return csugl::MakeRef<PerspectiveCamera>(aspect, near, far, fov);
        }
    };

}

#endif //CSUGL_CAMERA_H
